<?php

// $Id$


class Mail_SMTP_Settigns extends Tangra_Class {
	const ENC_NONE = 0;
	const ENC_TLS = 1;
	const ENC_SSL = 2;

	const PORT_DEFAULT = 25;
	const PORT_SECURE = 465;

	private $host;
	private $port = Mail_SMTP_Settigns::PORT_DEFAULT;
	private $use_auth = false;
	private $username;
	private $password;
	private $encryption = Mail_SMTP_Settigns::ENC_NONE;
	private $timeout = 15;


	function __construct($host, $username, $password, $port = Mail_SMTP_Settigns::PORT_DEFAULT, $timeout = 15, $use_auth = false, $encryption = Mail_SMTP_Settigns::ENC_NONE) {
		$this->set_host($host);
		$this->set_port($port);
		$this->set_timeout($timeout);
		$this->set_use_auth($use_auth);
		$this->set_username($username);
		$this->set_password($password);
		$this->set_encryption($encryption);
	}


	public function set_host($host) {
		$this->host = $host;
	}


	public function get_host() {
		return $this->host;
	}


	public function set_port($port) {
		$this->port = $port;
	}


	public function get_port() {
		return $this->port;
	}


	public function set_use_auth($use_auth) {
		$this->use_auth = $use_auth ? true : false;
	}


	public function get_use_auth() {
		return $this->use_auth;
	}


	public function set_username($username) {
		$this->username = $username;
	}


	public function get_username() {
		return $this->username;
	}


	public function set_password($password) {
		$this->password = $password;
	}


	public function get_password() {
		return $this->password;
	}


	public function set_encryption($encryption) {
		switch ($encryption) {
			case Mail_SMTP_Settigns::ENC_NONE:
			case Mail_SMTP_Settigns::ENC_TLS:
			case Mail_SMTP_Settigns::ENC_SSL:
				$this->encryption = $encryption;
				break;
			default:
				throw new Tangra_Module_Exception('Invalid encryption.');
				break;
		}
	}


	public function get_encryption() {
		return $this->encryption;
	}


	public function set_timeout($timeout = 15) {
		tangra_if_not_int_throw_e($timeout);
		$this->timeout = $timeout;
	}


	public function get_timeout() {
		return $this->timeout;
	}

}